<?php
include 'header.php';

require_once 'dbOper.php';
require 'GetStats.php';
require 'foodSearch.php';

session_start();

$stats = new GetStats();

echo "Hello ".$stats->getUser($_SESSION['username'])."!<br/>";
echo "Weight: ".$stats->getWeight($_SESSION['username'])."<br/>";
echo "Gender: ".$stats->getGender($_SESSION['username'])."<br/>";

$calories =
(($stats->getWeight($_SESSION['username']) * 10)  +
($stats->getHeight($_SESSION['username']) * 6.25) +
($stats->getAge($_SESSION['username']) * 5));

if ($stats->getGender($_SESSION['username']) == 'M')
{
	$calories+=5;
	echo "Resting calories requirement: ".$calories."<br/>";	
	echo "Activity modified calories requirement: ".$calories * $stats->getActivity($_SESSION['username'])."<br/>";
}
else if ($stats->getGender($_SESSION['username']) == 'F')
{
	$calories-=161;
	echo "Calores: ".$calories;
	echo "Activity modified calories requirement: ".$calories * $stats->getActivity($_SESSION['username'])."<br/>";
}
else 
	echo "If you want your calories calculated, enter your gender.";

if(isset($_POST['fSubmit']))
{
	echo "</br>Pick one of  the available options: </br>";
	$_SESSION['fSearch'] = $_POST['fSearch'];
	$fSearch = $_SESSION['fSearch'];
	$fRes = new GetFood();
	return $fRes->displayFoods($_SESSION['fSearch']);
	

}
			
?>	
<form action="<?php $_SERVER['PHP_SELF'];?>" method = "post">
<input type="text" name="fSearch" placeholder="search for food">
<input type="submit" name="fSubmit" value="Search">
</form>

<?php include 'footer.php';?>